<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataDt">
              <j-date placeholder="请输入数据日期" v-model="model.dataDt"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjgdm">
              <a-input v-model="model.jrjgdm" placeholder="请输入金融机构代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khmc">
              <a-input v-model="model.khmc" placeholder="请输入客户名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khzjlx">
              <a-input v-model="model.khzjlx" placeholder="请输入客户证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户证件代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khzjdm">
              <a-input v-model="model.khzjdm" placeholder="请输入客户证件代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="基本存款账号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jbckzh">
              <a-input v-model="model.jbckzh" placeholder="请输入基本存款账号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="基本账户开户行名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jbckzhkhhmc">
              <a-input v-model="model.jbckzhkhhmc" placeholder="请输入基本账户开户行名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="经营范围" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jyfw">
              <a-input v-model="model.jyfw" placeholder="请输入经营范围"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="注册资本" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zczb">
              <a-input-number v-model="model.zczb" placeholder="请输入注册资本" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="实收资本" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjcp">
              <a-input-number v-model="model.sjcp" placeholder="请输入实收资本" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="总资产" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zzc">
              <a-input-number v-model="model.zzc" placeholder="请输入总资产" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="营业收入" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yysr">
              <a-input-number v-model="model.yysr" placeholder="请输入营业收入" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="从业人员数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cyrys">
              <a-input-number v-model="model.cyrys" placeholder="请输入从业人员数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否上市公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfssgs">
              <a-input v-model="model.sfssgs" placeholder="请输入是否上市公司"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="首次建立信贷关系日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="scjlxdgxrq">
              <j-date placeholder="请选择首次建立信贷关系日期" v-model="model.scjlxdgxrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="注册地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zcdz">
              <a-input v-model="model.zcdz" placeholder="请输入注册地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="地区代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dqdm">
              <a-input v-model="model.dqdm" placeholder="请输入地区代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="经营状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jyzt">
              <a-input v-model="model.jyzt" placeholder="请输入经营状态"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="成立日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="clrq">
              <j-date placeholder="请选择成立日期" v-model="model.clrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="所属行业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sshy">
              <a-input v-model="model.sshy" placeholder="请输入所属行业"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="企业规模" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qygm">
              <a-input v-model="model.qygm" placeholder="请输入企业规模"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户经济成分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khjjcf">
              <a-input v-model="model.khjjcf" placeholder="请输入客户经济成分"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户国民经济部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khgmjjbm">
              <a-input v-model="model.khgmjjbm" placeholder="请输入客户国民经济部门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="授信额度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sxed">
              <a-input-number v-model="model.sxed" placeholder="请输入授信额度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="已用额度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yyed">
              <a-input-number v-model="model.yyed" placeholder="请输入已用额度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否关联方" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfglf">
              <a-input v-model="model.sfglf" placeholder="请输入是否关联方"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="实际控制人证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjkzrzjlx">
              <a-input v-model="model.sjkzrzjlx" placeholder="请输入实际控制人证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="实际控制人证件代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjkzrzjdm">
              <a-input v-model="model.sjkzrzjdm" placeholder="请输入实际控制人证件代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户信用级别总等级数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khxyjbzdjs">
              <a-input-number v-model="model.khxyjbzdjs" placeholder="请输入客户信用级别总等级数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户信用评级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khxypj">
              <a-input-number v-model="model.khxypj" placeholder="请输入客户信用评级" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="内部机构号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nbjgh">
              <a-input v-model="model.nbjgh" placeholder="请输入内部机构号"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'JsPNonIndCusInfoForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/jsPNonIndCusInfo/jsPNonIndCusInfo/add",
          edit: "/jsPNonIndCusInfo/jsPNonIndCusInfo/edit",
          queryById: "/jsPNonIndCusInfo/jsPNonIndCusInfo/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
